﻿using HandyControl.Controls;
using HandyControl.Tools.Command;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WcsZz.Extend;
using wms_wpf.Apiservice;
using wms_wpf.DialogView;
using wms_wpf.Views;

namespace wms_wpf.ViewModels
{
    public class MainWindowModel:BindableBase
    {
        public MainWindowModel(IRegionManager regionManager)
        {
            OpenPageCommand = new DelegateCommand<string>(OpenPage);
             _regionManager = regionManager;
            _regionManager.RegisterViewWithRegion("MainContent", typeof(MaterialView));
            EventAggregatorHelper.EventAggregator.ResgiterMessage(arg =>
            {
              UserName=arg.Message;

            }, "UserName");//选择Setting的消息聚合器
        }

        public DelegateCommand<string> OpenPageCommand { get; set; }
        private readonly IRegionManager _regionManager;

        private string userName;

        public string UserName
        {
            get { return userName; }
            set { userName = value; RaisePropertyChanged(); }
        }

        private async void OpenPage( string obj)
        {

            _regionManager.RequestNavigate("MainContent", obj);
   
        }

   
    }
}
